package com.example.observer.eventbus;

import java.util.ArrayList;
import java.util.Set;

public class EventBus {

    private ObserverRegistry registry = new ObserverRegistry();

    public void register(Object observer) {
        registry.register(observer);
    }

    public void post(Object event) {
        Set<ObserverAction> allActions = registry.getMacthedObserverActions(event);
        for (ObserverAction observerAction : allActions) {
            observerAction.invoke(event);
        }
    }
}
